/*
 * ---
 *
 * name: Browser.Mobile
 *
 * description: Provides useful information about the browser environment
 *
 * authors: Christoph Pojer (@cpojer)
 *
 * license: MIT-style license.
 *
 * requires: [Core/Browser]
 *
 * provides: Browser.Mobile
 *
 * ...
 */
(function(){Browser.Device={name:"other"};
if(Browser.Platform.ios){var a=navigator.userAgent.toLowerCase().match(/(ip(ad|od|hone))/)[0];Browser.Device[a]=true;Browser.Device.name=a;}if(this.devicePixelRatio==2){Browser.hasHighResolution=true;
}Browser.isMobile=!["mac","linux","win"].contains(Browser.Platform.name);}).call(this);(function(){[Element,Window,Document].invoke("implement",{hasEvent:function(f){var e=this.retrieve("events"),g=(e&&e[f])?e[f].values:null;
if(g){var d=g.length;while(d--){if(d in g){return true;}}}return false;}});var c=function(e,f,d){f=e[f];d=e[d];return function(h,g){if(d&&!this.hasEvent(g)){d.call(this,h,g);
}if(f){f.call(this,h,g);}};};var a=function(e,d,f){return function(h,g){d[f].call(this,h,g);e[f].call(this,h,g);};};var b=Element.Events;Element.defineCustomEvent=function(d,f){var e=b[f.base];
f.onAdd=c(f,"onAdd","onSetup");f.onRemove=c(f,"onRemove","onTeardown");b[d]=e?Object.append({},f,{base:e.base,condition:function(h,g){return(!e.condition||e.condition.call(this,h,g))&&(!f.condition||f.condition.call(this,h,g));
},onAdd:a(f,e,"onAdd"),onRemove:a(f,e,"onRemove")}):f;return this;};Element.enableCustomEvents=function(){Object.each(b,function(e,d){if(e.onEnable){e.onEnable.call(e,d);
}});};Element.disableCustomEvents=function(){Object.each(b,function(e,d){if(e.onDisable){e.onDisable.call(e,d);}});};})();Browser.Features.Touch=(function(){try{document.createEvent("TouchEvent").initTouchEvent("touchstart");
return true;}catch(a){}return false;})();Browser.Features.iOSTouch=(function(){var a="cantouch",c=document.html,f=false;if(!c.addEventListener){return false;
}var d=function(){c.removeEventListener(a,d,true);f=true;};try{c.addEventListener(a,d,true);var e=document.createEvent("TouchEvent");e.initTouchEvent(a);
c.dispatchEvent(e);return f;}catch(b){}d();return false;})();(function(){var a=function(c){if(!c.target||c.target.tagName.toLowerCase()!="select"){c.preventDefault();
}};var b;Element.defineCustomEvent("touch",{base:"touchend",condition:function(c){if(b||c.targetTouches.length!=0){return false;}var e=c.changedTouches[0],d=document.elementFromPoint(e.clientX,e.clientY);
do{if(d==this){return true;}}while(d&&(d=d.parentNode));return false;},onSetup:function(){this.addEvent("touchstart",a);},onTeardown:function(){this.removeEvent("touchstart",a);
},onEnable:function(){b=false;},onDisable:function(){b=true;}});})();if(Browser.Features.iOSTouch){(function(){var a="click";delete Element.NativeEvents[a];
Element.defineCustomEvent(a,{base:"touchend"});})();}if(Browser.Features.Touch){(function(){var a="pinch",d=a+":threshold",c,e;var b={touchstart:function(f){if(f.targetTouches.length==2){e=true;
}},touchmove:function(g){if(c||!e){return;}g.preventDefault();var f=this.retrieve(d,0.5);if(g.scale<(1+f)&&g.scale>(1-f)){return;}e=false;g.pinch=(g.scale>1)?"in":"out";
this.fireEvent(a,g);}};Element.defineCustomEvent(a,{onSetup:function(){this.addEvents(b);},onTeardown:function(){this.removeEvents(b);},onEnable:function(){c=false;
},onDisable:function(){c=true;}});})();}(function(){var a="swipe",c=a+":distance",f=a+":cancelVertical",g=50;var b={},e,d;var h=function(){d=false;};var i={touchstart:function(j){if(j.touches.length>1){return;
}var k=j.touches[0];d=true;b={x:k.pageX,y:k.pageY};},touchmove:function(l){if(e||!d){return;}var p=l.changedTouches[0],j={x:p.pageX,y:p.pageY};if(this.retrieve(f)&&Math.abs(b.y-j.y)>10){d=false;
return;}var o=this.retrieve(c,g),n=j.x-b.x,m=n<-o,k=n>o;if(!k&&!m){return;}l.preventDefault();d=false;l.direction=(m?"left":"right");l.start=b;l.end=j;
this.fireEvent(a,l);},touchend:h,touchcancel:h};Element.defineCustomEvent(a,{onSetup:function(){this.addEvents(i);},onTeardown:function(){this.removeEvents(i);
},onEnable:function(){e=false;},onDisable:function(){e=true;h();}});})();(function(){var b="touchhold",e=b+":delay",d,f;var a=function(g){clearTimeout(f);
};var c={touchstart:function(g){if(g.touches.length>1){a();return;}f=(function(){this.fireEvent(b,g);}).delay(this.retrieve(e)||750,this);},touchmove:a,touchcancel:a,touchend:a};
Element.defineCustomEvent(b,{onSetup:function(){this.addEvents(c);},onTeardown:function(){this.removeEvents(c);},onEnable:function(){d=false;},onDisable:function(){d=true;
a();}});})();